//
//  CompareViewController.m
//  CPU_Utility
//
//  Created by leonardo on 15/10/12.
//  Copyright © 2015年 leonardo. All rights reserved.
//

#import "CompareViewController.h"
#import "XCMultiSortTableView.h"
#import "CPUDetailModel.h"
#import <AFNetworking.h>
#import "Util.h"
#import <MJExtension.h>
#import <KVNProgress.h>
#import "UpdateResultShared.h"
#import "SearchViewController.h"
#import <GPUImageGaussianBlurFilter.h>
@interface CompareViewController ()<XCMultiTableViewDelegate,XCMultiTableViewDataSource>{
    UIImageView * _emptyImageView;
    

}

@end

@implementation CompareViewController{
    NSMutableArray * _headData;
    NSMutableArray * _leftTableData;
    NSMutableArray * _rightTableData;
    NSMutableArray * _rightTableHeaderData;
    int _reqCount;
}
- (instancetype)init
{
    self = [super init];
    if (self) {
        _ArrCpus = [NSMutableArray array];
        _isFromSearchChontroller = NO;
        
    }
    return self;
}
- (void)viewWillAppear:(BOOL)animated{
    [self initial];
    [self createUI];
    [self loadData];
    
    
    
    //出现时 未添加CPU 显示 无数据
    if(_ArrCpus == nil || _ArrCpus.count == 0){
        //没有数据, 显示 " 没有数据"
        _emptyImageView.hidden = NO;
        [KVNProgress dismiss];
        return;
    }
    else{
        [_emptyImageView setHidden:YES];
    }
   
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
   
    
}
//初始化
-(void)initial{
    for(UIView *subView in [self.view subviews])
    {
        [subView removeFromSuperview];
    }

    _headData = [NSMutableArray new];
    _leftTableData = [NSMutableArray new];
    _rightTableData = [NSMutableArray new];
    _rightTableHeaderData = [NSMutableArray new];
    
    _reqCount = 0;
}
//加载数据
-(void)loadData{
    /**
     *  GET /index.php?c=Iphone_37o_ProParam&proId=334039
     *  详细CPU参数
     */
    ;
    if (!_isFromSearchChontroller && ! _isFormSelectOldCPU && ! _isFormSelectNewCPU) {
        [_ArrCpus removeAllObjects];
        NSArray * arrIDs = [[NSUserDefaults standardUserDefaults] objectForKey:COMPARE_CPU_IDs];
        NSArray * arrNames = [[NSUserDefaults standardUserDefaults] objectForKey:COMPARE_CPU_NAMEs];
        for (int i = 0 ; i < arrIDs.count; i ++) {
            CPUDetailModel * model = [CPUDetailModel new];
            model.name = arrNames[i];
            model.productId = arrIDs[i];
            [_ArrCpus addObject:model];
        }
    }
    
    
    NSMutableDictionary * dictPara =[NSMutableDictionary dictionaryWithDictionary:  @{@"c":@"Iphone_37o_ProParam",@"proId":@"334039"}];
    _reqCount = 0;
    for (int i = 0;  i < _ArrCpus.count; i ++) {
        if (_ArrCpus != nil && _ArrCpus.count != 0 &&_ArrCpus[i]) {
          [KVNProgress showWithStatus:@"加载中..."];
 //           异步请求
             [ dictPara setValue:[(CPUDetailModel*)_ArrCpus[i] productId] forKey:@"proId"] ;
            AFHTTPRequestOperationManager * manaer = [Util getAFNetworkingManager];
            [manaer GET:URL_API parameters:dictPara success:^(AFHTTPRequestOperation * _Nonnull operation, id  _Nonnull responseObject) {
               ((CPUDetailModel*)_ArrCpus[i]).items =  [CPUDetailModelSection  objectArrayWithKeyValuesArray:responseObject];
                
               
             
                [self setTableView];
                [KVNProgress dismiss];
            


            } failure:^(AFHTTPRequestOperation * _Nonnull operation, NSError * _Nonnull error) {
                NSLog(@"网络错误:%@",error);
                [KVNProgress showErrorWithStatus:@"加载失败请重试"];
            }];
            
            //同步请求 正常
        
//            NSString *str = [NSString stringWithFormat:@"%@c=Iphone_37o_ProParam&proId=%@",URL_API,[(CPUDetailModel*)_ArrCpus[i] productId]];
//            NSURLRequest * req = [[NSURLRequest alloc]initWithURL:[NSURL URLWithString:str]];
//           // [self performSelectorInBackground:@selector(showHud) withObject:nil];
//            NSData * data = [NSURLConnection sendSynchronousRequest:req returningResponse:nil error:nil];
//           // NSLog(@"%@",data);
//           ((CPUDetailModel*)_ArrCpus[i]).items =  [CPUDetailModelSection  objectArrayWithKeyValuesArray:data];
//            [self setData];
//            _tableView.datasource = self;
//            //[self performSelectorInBackground:@selector(dismissHud) withObject:nil];
            
        }
        else{
            [KVNProgress dismiss];
            //return;
        }
       
    }
}
-(void)showHud{
    [KVNProgress show];
}
-(void)dismissHud{
    [KVNProgress dismiss];
}
// 处理获取的数据
-(void)setDataWithCPUs:(NSArray*)CPUs headData:(NSMutableArray*)headData  leftTableData:(NSMutableArray*)leftTableData rightTableData:(NSMutableArray*)rightTableData  rightTableHeaderData:(NSMutableArray*)rightTableHeaderData{
   // CPUDetailModel * cpuDetailModel1st = _ArrCpus[0];
    
    for (int i = 0 ; i < CPUs.count; i ++) { //遍历 cpu 个数
        [headData addObject:[CPUs[i] name]]; //顶部 CPU 名称
       
        CPUDetailModel * cpuDetailModel = CPUs[i];
        for (int j = 0; j < cpuDetailModel.items.count ;  j ++) {// 遍历每个 cpu的items或者说param
            CPUDetailModelSection * cpuDetailModelSection = cpuDetailModel.items[j];
            NSMutableArray * arrSectionLeft = [NSMutableArray array];
            NSMutableArray * arrSectionRight = [NSMutableArray array];
            if (![rightTableHeaderData containsObject:cpuDetailModelSection.name]) {//不含
                [rightTableHeaderData insertObject:cpuDetailModelSection.name atIndex:j];//rightTableheaders 大类
                [leftTableData insertObject:[NSMutableArray array] atIndex:j];
                [rightTableData insertObject:[NSMutableArray array] atIndex:j];
                
            }else{//含
               
                arrSectionLeft = leftTableData[[rightTableHeaderData indexOfObject:cpuDetailModelSection.name]];
                arrSectionRight = rightTableData[[rightTableHeaderData indexOfObject:cpuDetailModelSection.name]];
            }
          
            for (int z = 0 ; z < cpuDetailModelSection.paramArr.count;  z ++) {//
                CPUDetailModelCell * cpuDetailModelCell = cpuDetailModelSection.paramArr[z];
                //
                NSMutableArray * arrCellValuesNew = [NSMutableArray new];
                for (int  x = 0 ; x < CPUs.count; x ++ ) {
                    
                    [arrCellValuesNew addObject:@"暂无数据"];
                    
                }
                //
                
                //关键点 替换数据
                if (![arrSectionLeft containsObject:cpuDetailModelCell.name]) {
                    [arrSectionLeft insertObject:cpuDetailModelCell.name atIndex:z];
                    [arrSectionRight insertObject:[NSMutableArray array] atIndex:z];
                    
                    [arrCellValuesNew replaceObjectAtIndex:i withObject:cpuDetailModelCell.value];//以cell的value 替换"无数据"
                }
                else{
                    //修改cell里的数组
                    NSMutableArray * arrCellValuesOld = arrSectionRight[[arrSectionLeft indexOfObject:cpuDetailModelCell.name]];
                    [arrCellValuesNew replaceObjectsInRange:NSMakeRange(0, i  ) withObjectsFromArray:arrCellValuesOld range:NSMakeRange(0, i )];
                    [arrCellValuesNew replaceObjectAtIndex:i withObject:cpuDetailModelCell.value];
                }
                //
                [arrSectionRight replaceObjectAtIndex:[arrSectionLeft indexOfObject:cpuDetailModelCell.name] withObject:arrCellValuesNew ];
                
            }
            
          
            
            [leftTableData replaceObjectAtIndex:[rightTableHeaderData indexOfObject:cpuDetailModelSection.name] withObject:arrSectionLeft ];
           
            [rightTableData replaceObjectAtIndex:[rightTableHeaderData indexOfObject:cpuDetailModelSection.name] withObject:arrSectionRight];
        }
    }

    
    
}
//创建UI
-(void)createUI{
    //设置无数据 ImageView
//模糊效果
    GPUImageGaussianBlurFilter * blurFilter = [[GPUImageGaussianBlurFilter alloc] init];
    blurFilter.blurRadiusInPixels = 2.0;
    UIImage * image = [UIImage imageNamed:@"nocpu"];
    UIImage *blurredImage = [blurFilter imageByFilteringImage:image];
//    
    _emptyImageView = [UIImageView new];
    _emptyImageView.image = blurredImage;
    _emptyImageView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    _emptyImageView.backgroundColor = [UIColor cyanColor];
    //_emptyImageView.contentMode = UIViewContentModeScaleAspectFit;
    
    
    
    
    UILabel * label = [[UILabel alloc]initWithFrame:CGRectZero];
    label.text = @"至少有2款CPU才能对比\n请在搜索栏添加CPU";
    label.textColor = [UIColor redColor];
    label.numberOfLines = 2;
    label.textAlignment = NSTextAlignmentCenter;
    label.font = [UIFont boldSystemFontOfSize:25];
    [label sizeToFit];
    label.center = _emptyImageView.center;
    [_emptyImageView addSubview:label];
    [self.view addSubview:_emptyImageView];
    
    //navi 和 tabbar 设置
    //navi设置
    [self.navigationController.navigationBar setTranslucent:NO];
  
    //tabbar设置
    [self.tabBarController.tabBar setTranslucent:NO];
    
    [self setNavigationbar];
    
    
    
}
//设置navi bar
-(void)setNavigationbar{
    //设置加入对比按钮
    if (_isFromSearchChontroller) {
        //右边navition btn
        UIButton * btn = [UIButton buttonWithType:UIButtonTypeSystem];
        btn.frame = CGRectMake(0, 0, 50, 20);
        NSArray * arr = [[NSUserDefaults standardUserDefaults] arrayForKey:COMPARE_CPU_IDs];
        NSString * proId = [_ArrCpus[0] productId];
        BOOL isContained = NO;
        for (int i = 0 ; i < arr.count ; i ++) {
            if ([arr[i] isEqualToString:proId]) {
                isContained = YES   ;
                break;
            }
        }
        
        NSString * strBtnTitile = isContained? @"移出对比栏":@"加入对比栏";
        NSString * strCenterLabel = isContained? @"已加入对比栏":@"未加入对比栏";
        
        [btn addTarget:self action:isContained? @selector(btnRemoveFromCompare): @selector(btnAddToCompare) forControlEvents:UIControlEventTouchUpInside];
        [btn setTitle:strBtnTitile forState:UIControlStateNormal];
        [btn sizeToFit];
        
        self.navigationItem.rightBarButtonItem= [[UIBarButtonItem alloc] initWithCustomView:btn];
        //navi 中心label
        UILabel * labelCenter = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 20)];
        labelCenter.text = strCenterLabel;
        self.navigationItem.titleView = labelCenter;
        
    }
    else if (_isFormSelectNewCPU || _isFormSelectOldCPU) {
        UIButton * btn = [UIButton buttonWithType:UIButtonTypeSystem];
        btn.frame = CGRectMake(0, 0, 50, 20);
        [btn setTitle:@"确定" forState:UIControlStateNormal];
        [btn addTarget:self action:@selector(btnOKClicked) forControlEvents:UIControlEventTouchUpInside];
        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc ]initWithCustomView:btn];
    }
    
    else{//不是来自搜索栏
        
        
    }

}
#pragma btnOK 点击回调
-(void)btnOKClicked{
   
    [self.returnCPUDelegate setCPU:_ArrCpus[0] withIsOld:_isFormSelectOldCPU];
    if (_isFormSelectOldCPU) {
        [[UpdateResultShared Defaultshared] setOldCPU:_ArrCpus[0]];
        
        NSDictionary * dictSocketKeyValue = @{
        
         
                                              @"Socket AM3+" : @"p24828",
                                              @"Socket AM3" : @"p6209",
                                              @"Socket FM2+" : @"p27147",
                                              @"Socket FM2" : @"p23480",
                                              @"Socket FM1" : @"p21006",
                                              @"PGA 988" :   @"p27337-p27335",
                                              @"FCPGA 988" :   @"p27337-p27335",//同上
                                              @"Socket 947 rPGA" :   @"p27336",//四代
                                              @"BGA 1283" :    @"p27333",
                                              @"FCBGA 1283" :    @"p27333",//同上
                                              @"BGA 1364" :   @"p27331", //四五代
                                              @"FCBGA 1364" :   @"p27331",//同上
                                              @"BGA 1234" :    @"p27332",
                                              @"FCBGA 1234" :    @"p27332" ,//同上
                                              @"BGA 1168" :   @"p27317",//四五代低压
                                              //@"FCBGA1023，PPGA988" :    @"p27335",
                                              @"FCBGA1023，PPGA988" :    @"p27337-p27335",
                                              @"LGA 775" :     @"p10550",
                                              @"LGA 1150" :    @"p24844",
                                              @"LGA 1155" :    @"p16490",
                                              @"LGA 1170" :    @"p27330", //6代
                                              @"LGA 2011-v3" :   @"p27250",
                                              @"LGA 2011" :    @"p23417"
                                              };
          NSString * strName = [self getCellvaluesFormcellName:@"插槽类型" leftTableData:_leftTableData rightTableData:_rightTableData rightTableHeaderData:_rightTableHeaderData][0]  ;
        NSString * strValue = dictSocketKeyValue[strName];
        if(!strValue ){
            [self showHudNoSuport];
        }
        else{
            SearchViewController * vc = [SearchViewController new];
          
            vc.searchTerms.paramVal = strValue;
            vc.searchTerms.orderBy = @"4";
            vc.isFromSelectNewCPU = YES;
            [self.navigationController pushViewController:vc animated:YES];
        }
    }
    else if (_isFormSelectNewCPU) {
        [[UpdateResultShared Defaultshared] setNewCPU:_ArrCpus[0]];
        NSArray * arr = [NSMutableArray arrayWithArray:@[[UpdateResultShared Defaultshared].OldCPU,_ArrCpus[0]]];
        NSMutableArray * headDatai = [NSMutableArray new];
        NSMutableArray * leftTableDatai = [NSMutableArray new];
        NSMutableArray * rightTableDatai = [NSMutableArray new];
        NSMutableArray * rightTableHeaderDatai = [NSMutableArray new];
        [self setDataWithCPUs:arr headData:headDatai leftTableData:leftTableDatai rightTableData:rightTableDatai rightTableHeaderData:rightTableHeaderDatai];
        NSMutableString * strMsg = [NSMutableString new];
        NSArray * arrNames = @[@"CPU主频",@"核心数量",@"线程数",@"工作功率"];
        for (int i = 0 ; i < arrNames.count; i ++   ) {
            NSArray * arrValues =  [self getCellvaluesFormcellName:arrNames[i] leftTableData:leftTableDatai rightTableData:rightTableDatai rightTableHeaderData:rightTableHeaderDatai];
            if (![arrValues count]) {
                continue;
            }
            if (i == 3) {
                [strMsg appendString:[NSString stringWithFormat:@"\n发热功率(工作功率):%@----->%@",arrValues[0],arrValues[1]]];
                NSString * strTemp0 =arrValues[0];
                strTemp0 =  [strTemp0 substringToIndex:[strTemp0 length]-2];
                NSString * strTemp1 =arrValues[1];
                strTemp1 =  [strTemp1 substringToIndex:[strTemp1 length]-2];
                if ([strTemp0 intValue] < [strTemp1 intValue]) {
                    [strMsg appendString:@"\n您可能需要更换更强大散热器!"];
                }
                
                continue;
                
            }
            [strMsg appendString:[NSString stringWithFormat:@"\n%@----->%@",arrValues[0],arrValues[1]]];
            
            
        }
        
        UIAlertController * ac = [UIAlertController alertControllerWithTitle:@"注意" message:strMsg preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction * action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];
        [ac addAction:action];
        [ac.view setFrame:CGRectMake(0, 64, SCREEN_WIDTH, 500)];
        [self presentViewController:ac animated:YES completion:nil];
        
        
       
        
    }
    
}
-(NSArray *)getCellvaluesFormcellName:(NSString *) strName  leftTableData:(NSArray *)leftTableData rightTableData:(NSArray *)rightTableData rightTableHeaderData:(NSArray *)rightTableHeaderData {
    NSArray * arr = [NSArray new];
    for (int i = 0;  i < rightTableHeaderData.count;  i  ++) { //大类名称
        for (int  j = 0 ;  j < [leftTableData[i] count]; j ++) {
            if ([leftTableData[i][j] isEqualToString: strName]) {
               arr =   rightTableData[i][j];
                NSLog(@"%@",arr[0]);
            }
        }
        
    }
    return arr;
}
//点击移出对比栏
-(void)btnRemoveFromCompare{
    NSMutableArray *  cpuIDs = [[[NSUserDefaults standardUserDefaults] objectForKey:COMPARE_CPU_IDs] mutableCopy];
    if (!cpuIDs) {
        cpuIDs = [NSMutableArray new];
    }
    [cpuIDs removeObject:[_ArrCpus[0] productId]];
    [[NSUserDefaults standardUserDefaults] setObject:cpuIDs forKey:COMPARE_CPU_IDs];
    
    NSMutableArray * cpuNames = [[[NSUserDefaults standardUserDefaults] objectForKey:COMPARE_CPU_NAMEs] mutableCopy];
    if (!cpuNames) {
        cpuNames = [NSMutableArray new];
    }
    [cpuNames removeObject:[_ArrCpus[0] name]];
    [[NSUserDefaults standardUserDefaults] setObject:cpuNames forKey:COMPARE_CPU_NAMEs];
    
    NSMutableArray * cpuImages = [[[NSUserDefaults standardUserDefaults] objectForKey:COMPARE_CPU_IMAGEs]   mutableCopy];
    if (!cpuImages) {
        cpuImages = [NSMutableArray new];
    }
    [cpuImages removeObject:[_ArrCpus[0] smallImage]];
    [[NSUserDefaults standardUserDefaults] setObject:cpuImages forKey:COMPARE_CPU_IMAGEs];
    
    
    
    [self setNavigationbar];
    [KVNProgress showSuccessWithStatus:@"已经从对比栏移出"];
}
//点击 加入对比栏
-(void)btnAddToCompare{
    NSMutableArray *  cpuIDs = [[[NSUserDefaults standardUserDefaults] objectForKey:COMPARE_CPU_IDs] mutableCopy];
    if (!cpuIDs) {
        cpuIDs = [NSMutableArray new];
    }
    [cpuIDs addObject:[_ArrCpus[0] productId]];
    [[NSUserDefaults standardUserDefaults] setObject:cpuIDs forKey:COMPARE_CPU_IDs];
    
    NSMutableArray * cpuNames = [[[NSUserDefaults standardUserDefaults] objectForKey:COMPARE_CPU_NAMEs] mutableCopy];
    if (!cpuNames) {
        cpuNames = [NSMutableArray new];
    }
    [cpuNames addObject:[_ArrCpus[0] name]];
    [[NSUserDefaults standardUserDefaults] setObject:cpuNames forKey:COMPARE_CPU_NAMEs];
    
     NSMutableArray * cpuImages = [[[NSUserDefaults standardUserDefaults] objectForKey:COMPARE_CPU_IMAGEs] mutableCopy];
    
    if (!cpuImages) {
        cpuImages = [NSMutableArray new];
    }
    [cpuImages addObject:[_ArrCpus[0] smallImage]];
    [[NSUserDefaults standardUserDefaults] setObject:cpuImages forKey:COMPARE_CPU_IMAGEs];
    
    [self setNavigationbar];
    [KVNProgress showSuccessWithStatus:@"已经添加到对比栏"];
}
//设置table
-(void)setTableView{
    _reqCount ++;
    if(_reqCount == _ArrCpus.count){
        //整理数据
        [self setDataWithCPUs:_ArrCpus headData:_headData leftTableData:_leftTableData rightTableData:_rightTableData rightTableHeaderData:_rightTableHeaderData];
       
        // 设置 table
        //_tableView = [[XCMultiTableView alloc]initWithFrame:CGRectMake(50 , NAVI_HEIGHT, 320 , SCREEN_HEIGHT - NAVI_HEIGHT - TABBAR_HEIGHT )];
         NSLog(@"%f,%f",self.view.bounds.size.width,self.view.bounds.size.height);
        XCMultiTableView * _tableView =  [[XCMultiTableView alloc] initWithFrame:CGRectInset(self.view.bounds, 5.0f, 5.0f)];
        _tableView.delegate = self;
        _tableView.leftHeaderEnable = YES;
        _tableView.datasource = self;
        [self.view addSubview:_tableView];
        [KVNProgress dismiss];
    }
}
#pragma mark - XCMultiTableViewDataSource


- (NSArray *)arrayDataForTopHeaderInTableView:(XCMultiTableView *)tableView {
    
    
    return [_headData copy];
    
   // return [headData copy];
}
-(NSArray *)arrayDataForContenTableHeaderInTableView:(XCMultiTableView *)tableView{
    return [_rightTableHeaderData copy];
}
- (NSArray *)arrayDataForLeftHeaderInTableView:(XCMultiTableView *)tableView InSection:(NSUInteger)section {
    
    return [_leftTableData objectAtIndex:section];
}

- (NSArray *)arrayDataForContentInTableView:(XCMultiTableView *)tableView InSection:(NSUInteger)section {
    return [_rightTableData objectAtIndex:section];
}


- (NSUInteger)numberOfSectionsInTableView:(XCMultiTableView *)tableView {
    return [_leftTableData count];
}

- (AlignHorizontalPosition)tableView:(XCMultiTableView *)tableView inColumn:(NSInteger)column {
//    if (column == 0) {
        return AlignHorizontalPositionCenter;
//    }else if (column == 1) {
//        return AlignHorizontalPositionRight;
//    }
//    return AlignHorizontalPositionLeft;
}

- (CGFloat)tableView:(XCMultiTableView *)tableView contentTableCellWidth:(NSUInteger)column {
//    if (column == 0) {
//        return 500.0f;
//    }
    return 250.0f;
}

- (CGFloat)tableView:(XCMultiTableView *)tableView cellHeightInRow:(NSUInteger)row InSection:(NSUInteger)section {
//    if (section == 0) {
//        return 60.0f;
//    }else {
        return 30.0f;
//    }
}

- (UIColor *)tableView:(XCMultiTableView *)tableView bgColorInSection:(NSUInteger)section InRow:(NSUInteger)row InColumn:(NSUInteger)column {
//    if (row == 1 && section == 0) {
//        return [UIColor redColor];
//    }
    return [UIColor clearColor];
}

- (UIColor *)tableView:(XCMultiTableView *)tableView headerBgColorInColumn:(NSUInteger)column {
//    if (column == -1) {
//        return [UIColor redColor];
//    }else if (column == 1) {
//        return [UIColor grayColor];
//    }
    return [UIColor clearColor];
}

- (NSString *)vertexName {
    if (_ArrCpus.count >1) {
        return @"VS";
    }
    return @"";
}

#pragma mark - XCMultiTableViewDelegate

- (void)tableViewWithType:(MultiTableViewType)tableViewType didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"tableViewType:%@, selectedIndexPath: %@", @(tableViewType), indexPath);
}




#pragma mark - 显示HUD"不支持此CPU的升级"
- (void)showHudNoSuport{
    KVNProgressConfiguration *configuration = [[KVNProgressConfiguration alloc] init];
    //
    //        configuration.statusColor = [UIColor whiteColor];
    //        configuration.statusFont = [UIFont fontWithName:@"HelveticaNeue-Thin" size:15.0f];
    //        configuration.circleStrokeForegroundColor = [UIColor whiteColor];
    //        configuration.circleStrokeBackgroundColor = [UIColor colorWithWhite:1.0f alpha:0.3f];
    //        configuration.circleFillBackgroundColor = [UIColor colorWithWhite:1.0f alpha:0.1f];
    //        configuration.backgroundFillColor = [UIColor colorWithRed:0.173f green:0.263f blue:0.856f alpha:0.9f];
    //        configuration.backgroundTintColor = [UIColor colorWithRed:0.173f green:0.263f blue:0.856f alpha:1.0f];
    //        configuration.successColor = [UIColor whiteColor];
    //        configuration.errorColor = [UIColor whiteColor];
    
    configuration.circleSize = 0;
    configuration.lineWidth = 2.0f;
    configuration.fullScreen = YES;
    
    configuration.tapBlock = ^(KVNProgress *progressView) {
        [KVNProgress dismiss];
        [KVNProgress setConfiguration:[KVNProgressConfiguration new]];
        
    };
    
    // You can allow user interaction for behind views but you will losse the tapBlock functionnality just above
    // Does not work with fullscreen mode
    // Default is NO
    configuration.allowUserInteraction = YES;
    [KVNProgress setConfiguration:configuration];
    
    
    if (_isFormSelectOldCPU) {
        
        
        
        
        [KVNProgress showErrorWithStatus:@"暂时无法提供对此类型CPU的升级!"];
        
        
    }
    else if(_isFormSelectNewCPU){
   
        
    }
    
}








- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}




/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
